#!/bin/ash
if [ "`cat /etc/ss.sh | grep -c 915`" -lt 1 ]; then
	rm /etc/ss.sh
	wget http://routerdnsmasq.googlecode.com/git/ss.sh -O /etc/ss.sh
	wget http://routerdnsmasq.googlecode.com/git/915.json -O /etc/915.json
fi

if [ "`cat /etc/dnsmasq.conf | grep -c 9292014`" -lt 1 ]; then
	rm /etc/dnsmasq.conf
	wget http://routerdnsmasq.googlecode.com/git/dnsmasq_openwrt.conf -O /etc/dnsmasq.conf
fi

if [ "`cat /etc/hosts | grep -c 9152014`" -lt 1 ]; then
	rm /etc/hosts
	wget http://routerdnsmasq.googlecode.com/git/hosts_openwrt -O /etc/hosts
fi

if [ "`cat /etc/dns.sh | grep -c 9152014`" -lt 1 ]; then
	rm /etc/dns.sh
	wget http://routerdnsmasq.googlecode.com/git/dns.sh -O /etc/dns.sh
fi

if [ "`cat /etc/dns6.sh | grep -c 9152014`" -lt 1 ]; then
	rm /etc/dns6.sh
	wget http://routerdnsmasq.googlecode.com/git/dns6.sh -O /etc/dns6.sh
fi

if [ "`ifconfig | grep -c 172.16`" -gt 0 ]; then
	sed -i /etc/dnsmasq.conf -e 's/42.120.21.30/2001:67c:2b0::4/g' 
fi

if [ "`cat /etc/fqting/CHINA | grep -c 192.168.0.0/16`" -lt 1 ]; then
	sed -i '2i -A CHINA 192.168.0.0/16' /etc/fqting/CHINA
fi

if [ "`cat /etc/fqting/CHINA | grep -c 172.16.0.0/12`" -lt 1 ]; then
	sed -i '2i -A CHINA 172.16.0.0/12' /etc/fqting/CHINA
fi

if [ "`cat /etc/fqting/CHINA | grep -c 10.0.0.0/8`" -lt 1 ]; then
	sed -i '2i -A CHINA 10.0.0.0/8' /etc/fqting/CHINA
fi

chmod 755 /etc/*.sh
uci set network.wan.peerdns=0
#uci set network.wan.dns='192.168.10.8 114.114.114.114 208.67.222.222 202.14.67.4'
#uci set network.wan6.dns='2001:4860:4860::8888 2620:0:ccc::2'
sed -i /etc/config/network -e 's/192.168.10.8 61.60.224.5/192.168.10.8 114.114.114.114 208.67.222.222 208.67.220.220 202.14.67.4/g'
sed -i /etc/config/network -e 's/192.168.10.8 208.67.222.222/192.168.10.8 114.114.114.114 208.67.222.222 208.67.220.220 202.14.67.4/g'
sed -i /etc/config/network -e 's/192.168.10.8 8.8.8.8/192.168.10.8 114.114.114.114 208.67.222.222 208.67.220.220 202.14.67.4/g'
sed -i /etc/config/network -e 's/192.168.10.8/192.168.10.8 114.114.114.114 208.67.222.222 208.67.220.220 202.14.67.4/g'
#sed -i /etc/config/network -e 's/2001:3e0:0:10::12/2001:4860:4860::8888 2620:0:ccc::2/g'
#facebook
sed -i /etc/hosts -e 's/173.252.112.28/31.13.68.9/g'
sed -i /etc/hosts -e 's/173.252.100.19/69.171.242.23/g'
#dnsmasq change dns to tw
sed -i /etc/dnsmasq.conf -e 's/168.95.1.1/61.60.224.5/g'
#dns change dns to tw
sed -i /etc/config/network -e 's/60.61.224.5/61.60.224.5/g'
sed -i /etc/dnsmasq.conf -e 's/2001:3e0:0:10::12/61.60.224.5/g'
/etc/init.d/dnsmasq restart

